require 'rbof'

class App < OF::SimpleApp
  include OF
  
  def setup
    background 0, 0, 0
    setVerticalSync true
    
    @sound = SoundPlayer.new
    @sound.loadSound "1085.mp3"
    @sound.setLoop true
    @sound.play
  end
  
  def update
    @sound.setSpeed 2 * (1 - mouseY.to_f / getHeight)
    @sound.setPan mouseX.to_f / getWidth
  end
  
  def draw
    setColor 0xffffff
    drawBitmapString "move your mouse", 20, 40
    
    setColor 0xffff00
    w = 5
    soundGetSpectrum(81).each_with_index do |v, i|
      rect i * w, 200, w, -v * 800
      rect i * w, 200, w, v * 800
    end
  end
end

OF.setupOpenGL 400, 400, OF::WINDOW
OF.runApp App.new